package com.oa.dao.impl;

import java.sql.SQLException;

import com.oa.dao.BranchDepartDao;
import com.oa.pojo.BranchDepart;

public class BranchDepartDaoImpl
	extends CommonDao<BranchDepart>
	implements BranchDepartDao{

	@Override
	public BranchDepart getInstance(String departId) {
		String sql="select * from branchDepart where departId = ?";
		BranchDepart bd=null;
		try {
			open_db();
			pst=conn.prepareStatement(sql);
			pst.setString(1, departId);
			rs=pst.executeQuery();
			
			while (rs.next()) {
				bd=new BranchDepart();
				bd.setBranchId(rs.getInt("branchId"));
				bd.setBranchName(rs.getString("branchName"));
				bd.setDepartId(rs.getInt("departId"));
				bd.setDepartName(rs.getString("departName"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			close_db();
		}
		return bd;
	}

}
